import { Request, Response } from "express";
import { ModelExchangeRate } from "../models/ModelExchangeRate";

export const getExchangeRates = async (req: Request, resp: Response) => {
    const rates = await ModelExchangeRate.find()
    resp.json(rates)
}

export const createExchangeRates = async (req: Request, resp: Response) => {
    const { fromCurrency, toCurrency, rate } = req.body
    const exchangeRate = new ModelExchangeRate({ fromCurrency, toCurrency, rate })
    await exchangeRate.save()
    resp.json(exchangeRate)
}